package org.bud.boot.controller.test.service;

import org.bud.boot.controller.test.bit.Bud;
import org.bud.boot.mapper.BudMapper;
import org.bud.excel.expot.bit.ExportAskBody;
import org.bud.excel.expot.bit.QueryArg;
import org.bud.excel.expot.bit.SheetArg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author shaun
 * @date 2024/7/21
 * @instruction
 */
@Service
public class BudService {
    private BudMapper budMapper;

    public void  setBudMapper(BudMapper budMapper){
        this.budMapper = budMapper;
    }

    public ExportAskBody<?,?>[] aks(){
        return new ExportAskBody<?,?>[]{
                ExportAskBody.of(
                        SheetArg.builder()
                                .sheetName("你好")
                                .headerKeys(new String[]{"name", "score", "status"})
                                .headerNames(new String[]{"名称", "分数", "状态"}).build(),
                        QueryArg.<Bud, List<Bud>>builder()
                                .queryParam(new Bud())
                                .autoPage(true)
                                .data(budMapper::buds)
                                .build(),
                        null
                ), ExportAskBody.of(
                SheetArg.builder()
                        .sheetName("你好我更好")
                        .headerKeys(new String[]{"name", "score", "status"})
                        .headerNames(new String[]{"名称", "分数", "状态"}).build(),
                QueryArg.<Map<String, Object>, List<Map<String, Object>>>builder()
                        .queryParam(new HashMap<>())
                        .autoPage(true)
                        .data(budMapper::budList)
                        .build(),
                null
        )
        };
    }
}
